$(function(){
    obj.init();
});

var obj = new JsFun();
function JsFun(){
    'use strict';
    return {
        dataGrid: null,
        id:null,
        save:null,
        init: function () {
            this.save = window.top.xhTop.getModalConfirmDom();
            this.id = xhTool.getQuery('id');
            var form = new xhForm($('#xh_form'));
            form.parse().bindRequired($('#submit'));
            this.listener();
            if (info != 1) {
                var p = JSON.parse(info);
                form.fill(p);
                $("#key").attr("readonly","readonly");
            }
        },
        listener: function () {
            var $this = this;
            $('#cancel').click(function () {
                window.top.xhTop.closeModal();
            });

            $this.save.click(function () {
                $this.funObj().save();
            });
        },
        funObj: function(){
            var $this = this;
            return {
                save: function () {
                    $.ajax({
                        url:baseUrl+'user/storeUserConfigureData',
                        data:$('#xh_form').serialize(),
                        type:'POST',
                        success:function (data) {
                            window.top.xhTop.showSuccess(data.msg);
                            window.top.xhTop.getActiveFrame().location.reload();
                            window.top.xhTop.closeModal();
                        },
                        error:function (data) {
                            window.top.swal(
                                data['responseText'],
                                '',
                                'error'
                            );
                        }
                    });
                }
            }
        }
    }
}

